package com.zrentech.order.data.dbhelper.builder;

import android.content.ContentValues;
import android.database.Cursor;

import com.zrentech.order.data.busibean.FoodTypeBean;
import com.zrentech.order.data.dbhelper.DatabaseBuilder;

/**
 * 
 * 提供关于菜谱类型的创建和解析方面的功能
 * 
 * @author Leon
 */

public class FoodTypeDBuilder extends DatabaseBuilder<FoodTypeBean> {

	public static final String TRACK_ID = "id";
	public static final String TRACK_NAME = "name";
	public static final String TRACK_RATING = "rating";

	@Override
	public FoodTypeBean build(Cursor query) {
		int columnId = query.getColumnIndex(TRACK_ID);
		int columnName = query.getColumnIndex(TRACK_NAME);
		int columnRating = query.getColumnIndex(TRACK_RATING);

		FoodTypeBean menuType = new FoodTypeBean();
		menuType.setId(query.getInt(columnId));
		menuType.setName(query.getString(columnName));
		menuType.setRating(query.getDouble(columnRating));
		return menuType;
	}

	@Override
	public ContentValues deconstruct(FoodTypeBean track) {
		ContentValues values = new ContentValues();
		values.put(TRACK_ID, track.getId());
		values.put(TRACK_NAME, track.getName());
		values.put(TRACK_RATING, track.getRating());
		return values;
	}

}
